package com.bw.controller;

import com.bw.common.ResultModel;
import com.bw.domain.TraceLngLat;
import com.bw.domain.TraceTransport;
import com.bw.service.TraceLngLatService;
import com.bw.service.TraceTransportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author GumpSeen
 * @DateTime 2023/8/25 10:32
 */
@RestController
@RequestMapping("/driver")
public class DriverController {
    @Autowired
    TraceTransportService traceTransportService;
    @Autowired
    TraceLngLatService traceLngLatService;
    @RequestMapping("/list")
    public ResultModel list(String driverId){
        List<TraceTransport> transportList = traceTransportService.selectAll(driverId);
        return ResultModel.successed(transportList);
    }

    @PostMapping("/saveTransport")
    public ResultModel saveTransport(@RequestBody TraceLngLat traceLngLat){
        TraceTransport transport = new TraceTransport();
        transport.setOutFactoryStatus(traceLngLat.getOutFactoryStatus());
        transport.setId(traceLngLat.getId());
        transport.setCropsId(traceLngLat.getCropsId());
        transport.setStatus(traceLngLat.getStatus());
//        traceLngLatService.save(traceLngLat);
        traceTransportService.updateById(transport);
        return ResultModel.successed(true);
    }

}
